package com.fastwire.carriere.hibernate.daoimpl;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;

import com.fastwire.carriere.common.util.DateUtil;
import com.fastwire.carriere.dao.DAOException;
import com.fastwire.carriere.dao.NetworkInventoryDao;
import com.fastwire.carriere.inventory.entity.NetworkEntityUserSpecificInfo;

public class NetworkInventoryDaoImpl extends AbstractDAOImpl implements
		NetworkInventoryDao {

	@Override
	public NetworkEntityUserSpecificInfo getNetworkEntityUserSpecificInfobyNameAndType(
			String name, String type) throws DAOException {

		DetachedCriteria criteria = DetachedCriteria
				.forClass(NetworkEntityUserSpecificInfo.class);
		criteria.add(Restrictions.and(Restrictions.eq("name", name),
				Restrictions.eq("type", type)));
		return (NetworkEntityUserSpecificInfo) getHibernateTemplate()
				.findSingleObjByCriteria(criteria, false, true);
	}

	@Override
	public void saveOrUpdateNetworkEntityUserSpecificInfo(
			NetworkEntityUserSpecificInfo info) throws DAOException {
		info.setLastModifiedDate(DateUtil.getDate());
		saveOrUpdate(info);

	}
}
